package com.huitu.whht.base.core.api.geo.intx;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.base.core.api.geo.intx.entities.GeoIntQo;
import com.huitu.whht.base.core.api.geo.intx.service.IGeoIntCoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Component
@SzyCoreApiResource
@Path("geo/intx")
public class GeoIntCoreResource extends AbstractApiResource {
    private static final Logger logger = LoggerFactory.getLogger(GeoIntCoreResource.class);
    private static final String UUID = "0cbf5b72-9e45-4bfa-818a-61f8a0fb25d4";
    @Override
    public String getUUID() {
        return UUID;
    }
    @Autowired
    @SzyCoreApiService
    private IGeoIntCoreService geoIntCoreService;
    /**
     * @api {get} geo/intx/{intCd:\\w{12}} [R]根据主键查询
     * @apiDescription 根据主键查询GEO_INT_5T地表水取水口空间信息数据
     * @apiName select by primary key
     * @apiGroup GEO_S05_0002-地表水取水口空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/intx/420222000011
     * @apiParam {String}         intCd              【必须】地表水取水口代码
     * @apiSuccess {String}         intCd              地表水取水口代码
     * @apiSuccess {String}         intNm              地表水取水口名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "intCd": "420222000011",
     * "intNm": "外牧羊湖灌区取水口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 0
     * }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{intCd:\\w{12}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("intCd") String intCd) {
        logger.info("根据主键查询 地表水取水口空间信息,参数 intCd:{}", intCd);
        return Response.ok(ApiResultBuilder.create(this, geoIntCoreService.selectByPrimaryKey(intCd))).build();
    }
    /**
     * @api {post} geo/intx/list [R]根据条件查询(含空间信息)
     * @apiDescription 根据条件查询GEO_INT_5T地表水取水口空间信息数据(含空间信息)
     * @apiName select by filter
     * @apiGroup GEO_S05_0002-地表水取水口空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/intx/list
     * @apiParam {List(String)}   intCdList          (数组)地表水取水口代码
     * @apiParam {String}         intCd              地表水取水口代码
     * @apiParam {String}         intNm              地表水取水口名称
     * @apiParam {List(String)}   intTpList          (数组)取水方式
     * @apiParam {Date}           fromIntDtBgTm      (开始时间)开始取水日期
     * @apiParam {Date}           fromIntDtEdTm      (结束时间)开始取水日期
     * @apiParam {Double}         maxPermQMin        (最小)许可最大流量
     * @apiParam {Double}         maxPermQMax        (最大)许可最大流量
     * @apiParam {Double}         desQMin            (最小)设计流量
     * @apiParam {Double}         desQMax            (最大)设计流量
     * @apiParam {Double}         permWwMin          (最小)许可总取水量
     * @apiParam {Double}         permWwMax          (最大)许可总取水量
     * @apiParam {List(String)}   runCondList        (数组)运行状况
     * @apiParam {List(String)}   engManCdList       (数组)管理单位代码
     * @apiParam {String}         engManCd           管理单位代码
     * @apiParam {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam {String}         nt                 备注
     * @apiParam {String}         wsReg              供水范围
     * @apiParam {List(String)}   intCalWayList      (数组)取水量计算方法
     * @apiParam {List(String)}   isIrrhdList        (数组)是否为灌区渠首
     * @apiParam {Double}         conIrrAMin         (最小)口门控制面积
     * @apiParam {Double}         conIrrAMax         (最大)口门控制面积
     * @apiSuccess {String}         intCd             地表水取水口代码
     * @apiSuccess {String}         intNm             地表水取水口名称
     * @apiSuccess {String}         lgtd              经度
     * @apiSuccess {String}         lttd              纬度
     * @apiSuccess {String}         shape             空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "intCd": "420222000011",
     * "intNm": "外牧羊湖灌区取水口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 0
     * }]
     * }
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "intCd": "420222000011",
     * "intNm": "外牧羊湖灌区取水口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "rowId": 1
     * },
     * {
     * "intCd": "420222000011",
     * "intNm": "外牧羊湖灌区取水口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "rowId": 2
     * }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public  Response selectList(GeoIntQo filter){
        PageUtils.startPageFromRang();
        logger.info("根据条件查询 地表水取水口空间信息，参数GeoIntQo{}",filter);
        return  Response.ok(ApiResultBuilder.create(this,geoIntCoreService.selectList(filter))).build();
    }
}
